Skip to content

Fix DRA nodeSelector for in-tree driver mode#1851

Merged
openshift-merge-bot[bot] merged 1 commit into
rh-ecosystem-edge:mainfrom
TomerNewman:fix/dra-node-selector
Jul 9, 2026
Merged

Fix DRA nodeSelector for in-tree driver mode#1851
openshift-merge-bot[bot] merged 1 commit into
rh-ecosystem-edge:mainfrom
TomerNewman:fix/dra-node-selector

Conversation

@TomerNewman

@TomerNewman TomerNewman commented Jul 9, 2026

Copy link
Copy Markdown
Member

When spec.moduleLoader is nil (in-tree mode), the DRA reconciler's nodeSelector requires the KMM ready label, which is never set because no module loading occurs. Fall back to spec.selector instead, matching the existing behavior in the device plugin reconciler.


/cc @ybettan @yevgeny-shnaidman
/assign @ybettan @yevgeny-shnaidman


fix #1850

Summary by CodeRabbit

  • Bug Fixes
    • Updated node selection behavior so workloads now follow the module’s configured selector when no module loader is set.
    • Preserved version-based node selection for module-loader setups when a container version is provided.
    • Adjusted the expected scheduling behavior in automated checks to match the new selection rules.

When spec.moduleLoader is nil (in-tree mode), the DRA reconciler's
nodeSelector requires the KMM ready label, which is never set because
no module loading occurs. Fall back to spec.selector instead, matching
the existing behavior in the device plugin reconciler.

Signed-off-by: Anthony Byrne <abyrne@redhat.com>
@netlify

netlify Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy Preview for openshift-kmm ready!

Name Link
🔨 Latest commit ac473dd
🔍 Latest deploy log https://app.netlify.com/projects/openshift-kmm/deploys/6a4f6fc88bf3600008f3d950
😎 Deploy Preview https://deploy-preview-1851--openshift-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TomerNewman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The DRA reconciler's setDRAAsDesired function now sets nodeSelector to mod.Spec.Selector when ModuleLoader is nil, instead of leaving it as the default kernel-module-ready selector. The version label is added only when ModuleLoader is set with a non-empty Container.Version. The corresponding test's expected NodeSelector was updated to match.

Changes

DRA nodeSelector fallback fix

Layer / File(s) Summary
nodeSelector fallback for in-tree mode
internal/controllers/dra_reconciler.go, internal/controllers/dra_reconciler_test.go
setDRAAsDesired assigns nodeSelector = mod.Spec.Selector when ModuleLoader is nil, and only adds the version label when ModuleLoader is present with a non-empty Container.Version; test expectation updated to expect {"has-feature-x": "true"} as NodeSelector.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: yevgeny-shnaidman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: changing DRA nodeSelector behavior for in-tree driver mode.
Linked Issues check ✅ Passed The changes implement the linked issue's fix by falling back to spec.selector when moduleLoader is nil, and the test was updated.
Out of Scope Changes check ✅ Passed The diff stays focused on the DRA nodeSelector fix and its test coverage, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/controllers/dra_reconciler.go (1)

552-553: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider defensive copy of mod.Spec.Selector to avoid shared map reference.

When ModuleLoader is nil, nodeSelector = mod.Spec.Selector assigns the same underlying map to both the Module spec and the DaemonSet's NodeSelector. While no modifications occur after this point in the current code, a future change that mutates the DaemonSet's NodeSelector would silently corrupt mod.Spec.Selector. This pattern is consistent with device_plugin_reconciler.go, so it's not a blocking concern.

♻️ Optional defensive copy
 	} else {
-		nodeSelector = mod.Spec.Selector
+		nodeSelector = make(map[string]string, len(mod.Spec.Selector))
+		for k, v := range mod.Spec.Selector {
+			nodeSelector[k] = v
+		}
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controllers/dra_reconciler.go` around lines 552 - 553, Defensively
copy mod.Spec.Selector before assigning it to nodeSelector in the DRA reconciler
fallback path, since the current direct assignment shares the underlying map
with the Module spec. Update the branch in the reconciler that handles the nil
ModuleLoader case so the DaemonSet’s NodeSelector gets its own copy, matching
the safer pattern used in device_plugin_reconciler.go and avoiding accidental
mutation of mod.Spec.Selector.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/controllers/dra_reconciler.go`:
- Around line 552-553: Defensively copy mod.Spec.Selector before assigning it to
nodeSelector in the DRA reconciler fallback path, since the current direct
assignment shares the underlying map with the Module spec. Update the branch in
the reconciler that handles the nil ModuleLoader case so the DaemonSet’s
NodeSelector gets its own copy, matching the safer pattern used in
device_plugin_reconciler.go and avoiding accidental mutation of
mod.Spec.Selector.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a086002e-8ffe-482f-b438-0cb9c95b4976

📥 Commits

Reviewing files that changed from the base of the PR and between 8330a67 and ac473dd.

📒 Files selected for processing (2)
  • internal/controllers/dra_reconciler.go
  • internal/controllers/dra_reconciler_test.go

@yevgeny-shnaidman

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jul 9, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit d27863e into rh-ecosystem-edge:main Jul 9, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cherry-picking error for 01cb4ad80f22b056db213400662d7b5da14b2581

4 participants